import {
  mapGetters,
  mapMutations
} from 'vuex'
export default {
  data() {
    return {
      inpValue: '',
      editAble: false,
      isUpdate: false, //标记数据是否发生变化
      word: '',
      noIconColumns: [ //这些列头即使数据修改也不会显示修改标识
        'durationType',
        'healthStatusType',
        'modifier',
        'physicalCompletePercent',
        'taskCode',
        'thePersistInfo.createStamp',
        'lineNumber',
        'plannableStatus',
        'lock.lockDate',
        'thePersistInfo.modifyStamp',
        'actualEndDate',
        'creator',
        'lock.locker',
        'KeyNode',
        'deliverable'
      ],
      stateLimit: [
        'COMPLETED',
        'PENDINGAPPROVAL'
      ]
    }
  },
  props: {
    data: {
      type: Object,
      default: () => {}
    },
    columnInfo: {
      type: Object,
      default: () => {}
    },
    //编辑弹出框标识位
    isEdit: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    ...mapGetters({
      dataSource: 'getPlanTable',
      isAddNode: 'isAddNode'
    }),
    noIconForCol() {
      return this.noIconColumns.includes(this.word)
    },
    isChild() {
      return this.data.activityType != 'WBS'
    },
    //只有未发布  进行中  的任务才能编辑
    statePermission() {
      return !this.stateLimit.includes(this.data.plannableStatus)
    }
  },
  watch: {
    data: {
      handler(n) {
        //数据是否修改
        const compareNode = this.$store.state.planTable.compareDefaultTable.find(item => item.id == this.data.id)
        if (compareNode == undefined || JSON.stringify(compareNode[this.word]) != JSON.stringify(this.data[this.word])) {
          this.isUpdate = true
        } else {
          this.isUpdate = false
        }
        this.inpValue = n[this.word]
        this.dataUpdate != undefined && this.dataUpdate(n)
      },
      deep: true,
    }
  },
  mounted() {
    this.word = this.columnInfo.dataIndex
    this.inpValue = this.data[this.word]
    this.init != undefined && this.init()
  },
  methods: {
    ...mapMutations([ 'setRowOfPlanTable'])
  }
}